<template>
    <div>
        <el-container style="height: 500px; border: 1px solid #eee">
            <el-header>
                <span style="font-size: 25px; font-weight: 800; letter-spacing: 20px; color: white;">
                    教务管理系统
                </span>
                <el-dropdown style="font-size: 12px;float: right; color: #eee;">
                    <i class="el-icon-setting" style="margin-right: 15px"></i>
                    <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item @click.native="addAdmin">新增</el-dropdown-item>
                    <el-dropdown-item @click.native="logout">注销</el-dropdown-item>
                    </el-dropdown-menu>
                    <span>{{ username }}</span>
                </el-dropdown>
                
            </el-header>
            <el-container>
            <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
                <el-menu :default-openeds="['1', '3']">
                <el-submenu index="1">
                    <template slot="title"><i class="el-icon-user-solid"></i>学生管理</template>
                    <el-menu-item-group>
                        <template slot="title">学生信息管理</template>
                        <router-link to="/home/student/query">
                            <el-menu-item index="1-1">查询学生</el-menu-item>
                        </router-link>
                    </el-menu-item-group>
                    <el-menu-item-group>
                        <template slot="title">学生课程管理</template>
                        <router-link to="/home/student/querySC">
                            <el-menu-item index="1-3">学生课程</el-menu-item>
                        </router-link>
                    </el-menu-item-group>
                </el-submenu>
                <el-submenu index="2">
                    <template slot="title"><i class="el-icon-s-custom"></i>教师管理</template>
                    <el-menu-item-group>
                        <template slot="title">教师信息管理</template>
                        <router-link to="/home/teacher/query">
                            <el-menu-item index="2-1">查询教师</el-menu-item>
                        </router-link>
                    </el-menu-item-group>
                    <el-menu-item-group>
                        <template slot="title">教师排课管理</template>
                        <router-link to="/home/teacher/appointment">
                            <el-menu-item index="2-4">教师排课</el-menu-item>
                        </router-link>
                    </el-menu-item-group>
                </el-submenu>
                <el-submenu index="3">
                    <template slot="title"><i class="el-icon-s-order"></i>课程管理</template>
                    <el-menu-item-group>
                        <template slot="title">课程信息管理</template>
                        <router-link to="/home/course/query">
                            <el-menu-item index="3-1">查询课程</el-menu-item>
                        </router-link>
                    </el-menu-item-group>
                </el-submenu>
                </el-menu>
            </el-aside>                
            <el-main>
                <router-view></router-view>
            </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script>
    export default {
        name:"Home",
        data() {
            return {
                username:"管理员",
            }
        },
        created() {
            this.username = localStorage.getItem("username");
        },
        methods: {
            logout() {
                localStorage.removeItem("username");
                localStorage.removeItem("password");
                this.$router.replace({
                    name:'login', 
                })
            },
            addAdmin() {
                this.$router.replace({
                    name:'addAdmin', 
                })
            }
        }
    }
</script>

<style>
    .el-header {
        background-color: #5f646a;
        color: #333;
        line-height: 60px;
        overflow:hidden;
    }
  
    .el-aside {
        color: #333;
        height: 800px;
    }
    .el-menu-item {
        margin-left: 22px;
    }
</style>